package com.xmg.boot.demo.bootlesson1.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.cj.util.StringUtils;
import com.xmg.boot.demo.bootlesson1.user.entity.dto.StudentDto;
import com.xmg.boot.demo.bootlesson1.user.entity.pojo.Student;
import com.xmg.boot.demo.bootlesson1.user.mapper.StudentMapper;
import com.xmg.boot.demo.bootlesson1.user.service.StudentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mwd
 * @create 2023-11-22
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, StudentDto> implements StudentService {
    @Override
    public List<StudentDto> getStudentLst(String sName,int cId) {
        LambdaQueryWrapper<StudentDto> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        if(!StringUtils.isNullOrEmpty(sName)){
            lambdaQueryWrapper.like(StudentDto::getStuName,sName);
        }
        if(cId>0){
            lambdaQueryWrapper.ge(StudentDto::getCId,cId);
        }
        return this.baseMapper.getStudentDto(lambdaQueryWrapper);
    }
}
